package com.zenithmind.chat.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.util.List;

@Data
@Schema(description = "AI对话DTO")
public class AiChatDTO {
    
    private String id;
    
    @NotBlank(message = "标题不能为空")
    @Schema(description = "对话标题")
    private String title;
    
    @NotNull(message = "模型类型不能为空")
    @Schema(description = "模型类型(1-OpenAI,2-Ollama,3-Azure,4-Anthropic,5-自定义)")
    private Integer modelType;
    
    @NotBlank(message = "模型名称不能为空")
    @Schema(description = "模型名称")
    private String modelName;
    
    @Schema(description = "系统提示词")
    private String systemPrompt;
    
    @Schema(description = "状态(0-禁用,1-启用)")
    private Integer status;
    
    @Schema(description = "是否收藏(0-否,1-是)")
    private Integer isFavorite;
    
    @Schema(description = "标签列表")
    private List<String> tags;
    
    @Schema(description = "共享类型(0-私有,1-公开,2-指定用户)")
    private Integer shareType;
    
    @Schema(description = "共享用户ID列表")
    private List<String> sharedUserIds;
    
    @Schema(description = "温度值(影响随机性,0.0-2.0)")
    private Float temperature;
    
    @Schema(description = "最大生成token数")
    private Integer maxTokens;
    
    /**
     * 设置模型名称的同时，根据模型名称推断模型类型
     */
    public void setModelName(String modelName) {
        this.modelName = modelName;
        // 如果已设置模型类型，则不覆盖
        if (this.modelType == null && modelName != null) {
            // 根据模型名称推断类型
            if (modelName.contains("qwen") || modelName.contains("ollama")) {
                this.modelType = 2; // Ollama
            } else if (modelName.contains("gpt") || modelName.contains("text-davinci")) {
                this.modelType = 1; // OpenAI
            } else if (modelName.contains("claude")) {
                this.modelType = 4; // Anthropic
            } else if (modelName.contains("azure")) {
                this.modelType = 3; // Azure
            } else {
                this.modelType = 5; // 自定义
            }
        }
    }
} 